﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

namespace PicShare.Server.Helpers
{
    public static class AlbumHelper
    {
        public static Dictionary<string, List<string>> ConvertStringToDictionary(dynamic obj)
        {
            var currentMultiDictionary = new Dictionary<string, List<string>>();

            var serializer = new JavaScriptSerializer();
            serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
            var tempObj = serializer.Deserialize(obj, typeof(object));

            var dictionary = tempObj.DictionaryObj;

            foreach (var item in dictionary)
            {
                var list = new List<string>();

                foreach (var currentItem in item.Value)
                {
                    list.Add(currentItem);
                }

                currentMultiDictionary.Add(item.Key, list);
            }

            return currentMultiDictionary;
        }

    }
}